"""
@title(TenX腾晓2024年11月考核答题文件)
@warning(请勿修改参数和返回值)
@warning(请认真填写__init__中的数据)
@author(1323230180)
"""
from typing import List, Tuple


class TenXClass:
    def __init__(self):
        self.name = "张志南"
        self.id = "3124002023"

    @staticmethod
    def question1(n: int) -> list[str]:
        print(n)  # 打印，防止IDE警告
        result = []
        for i in range(1, n + 1):
            answer = ""
            num = i
            if num == 0:
                answer = "0"
            while num > 0:
                answer = str(num % 4) + answer
                num //= 4
            result.append(answer)
        return result

    @staticmethod
    def question2() -> list[tuple[int, int, int]]:
        result = []
        for x in range(20):
            for y in range(33):
                z = 100 - x - y
                if 5 * x + 3 * y + z / 3 == 100 and z % 3 == 0:
                    result.append((x, y, z))
        return result

    @staticmethod
    def question3(equipment: list[str], prop: list[str], material: list[str], items: list[str]) -> dict[str, list[str]]:
        print(equipment, prop, material, items)  # 打印，防止IDE警告
        result = {
            "equipment": [],
            "prop": [],
            "material": []
        }
        for item in items:
            if item in equipment:
                result["equipment"].append(item)
            elif item in prop:
                result["prop"].append(item)
            elif item in material:
                result["material"].append(item)
        return result

    @staticmethod
    def question4(item_values: dict[str, int], items: list[str]) -> tuple[list[str], int]:
        print(item_values, items)  # 打印，防止IDE警告
        item_value_pairs = []
        for item in items:
            if item in item_values:
                item_value_pairs.append((item, item_values[item]))
        sorted_pairs = sorted(item_value_pairs, key=lambda x: x[1], reverse=True)
        selected_pairs = sorted_pairs[:3]
        selected_items = [pair[0] for pair in selected_pairs]
        total_value = sum([pair[1] for pair in selected_pairs])
        return (selected_items, total_value)

    @staticmethod
    def question5(matrix: list[list[int]]) -> list[tuple[int, int]]:
        print(matrix)  # 打印，防止IDE警告
        result = []
        for x in range(len(matrix)):
            for y in range(len(matrix[x])):
                if matrix[x][y] == 0:
                    result.append((x + 1, y + 1))
        return result
